package com.test5;

import java.io.FileReader;

public class FileReaderTEst {
    public static void main(String[] args) throws Exception {
        //创建FileReader，文件字符输入流
        FileReader fr = new FileReader("C:\\Users\\LDH\\Desktop\\test2.txt");
        //读取
        //单个字符读取
//        int data = 0;
//        while ((data = fr.read()) != -1){
//            System.out.println((char) data);
//        }
        //多个字符读取
        char[] buf = new char[2];
        int count = 0;
        while ((count = fr.read(buf)) != -1){
            System.out.println(new String(buf,0,count));
        }
        //关闭
        fr.close();
    }
}
